const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');

const MapService = sequelize.define('MapService', {
  id: {
    type: DataTypes.UUID,
    defaultValue: DataTypes.UUIDV4,
    primaryKey: true
  },
  provider: {
    type: DataTypes.ENUM('tencent', 'amap', 'tianditu'),
    allowNull: false,
    comment: '地图服务提供商'
  },
  api_key: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: 'API密钥'
  },
  status: {
    type: DataTypes.ENUM('active', 'inactive'),
    defaultValue: 'active',
    comment: '地图服务状态'
  },
  config: {
    type: DataTypes.JSON,
    defaultValue: {}
  },
  usage_quota: {
    type: DataTypes.INTEGER,
    comment: '使用配额'
  },
  usage_count: {
    type: DataTypes.INTEGER,
    defaultValue: 0,
    comment: '使用次数'
  },
  last_used_at: {
    type: DataTypes.DATE,
    comment: '最后使用时间'
  },
  expires_at: {
    type: DataTypes.DATE,
    comment: '过期时间'
  },
  metadata: {
    type: DataTypes.JSON,
    defaultValue: {}
  }
}, {
  underscored: true,
  comment: '地图服务信息表'
});

module.exports = MapService; 